home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 6_17.lha / 6_17 / 6_17a22.c < prev    next >
C/C++ Source or Header  |  1993-08-08  |  425b  |  19 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / x = v1 - 5.0
  6. ector& operator-(vector &v1, float x)
  7.  
  8.    // allocate the new vector
  9.    int l = v1.p->length;
  10.    vector *v = new vector(l);
  11.  
  12.    // do the operations
  13.    float *f = v->p->f;
  14.    float *f1 = v1.p->f;
  15.    for (int i = 0; i < l; i++, f++, f1++)
  16. *f = *f1 - x;
  17.    return *v;
  18.  
  19.